package chapter2.section3;

/**
 * 程序 2-4：一个算术运算的程序
 *
 * @author 张玮婷 20245080902061
 */

public class ArithmeticDemo {
    public static void main(String[] args) {
        //a few numbers
        int i = 37;
        int j = 42;
        double x = 27.475;
        double y = 7.22;
        System.out.println("Variable values...");
        System.out.println("    i=" + i);
        System.out.println("    j=" + j);
        System.out.println("    x=" + x);
        System.out.println("    y=" + y);

        //adding numbers
        System.out.println("Adding...");
        System.out.println("    i+j=" + (i + j));
        System.out.println("    x+y=" + (x + y));

        //subtracting numbers
        System.out.println("Subtracting...");
        System.out.println("    i-j=" + (i - j));
        System.out.println("    x-y=" + (x - y));

        //multiplying numbers
        System.out.println("Multiplying...");
        System.out.println("    i*j=" + (i * j));
        System.out.println("    x*y=" + (x * y));

        //dividing numbers
        System.out.println("Dividing...");
        System.out.println("    i/j=" + (i / j));
        System.out.println("    x/y=" + (x / y));

        //computing the remainder resulting
        //from dividing numbers
        System.out.println("Computing the remainder");
        System.out.println("    i%j=" + (i % j));
        System.out.println("    x%y=" + (x % y));

        //mixing types
        System.out.println("Mixing types...");
        System.out.println("    j+y=" + (j + y));
        System.out.println("    i*x=" + (i * x));

        //increment operation
        System.out.println("increment...");
        System.out.println("    i++=" + (i++));
        //先输入i的值，再执行加1的操作
        System.out.println("    ++j=" + (++j));
        //先执行加1的操作，再输出j的值
        //decrement operation
        System.out.println("decrement...");
        System.out.println("    i--=" + (i--));
        System.out.println("    --j=" + (--j));
    }

}

